package com.oitsm.mo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oitsm.mo.cache.NodeCache;
import com.oitsm.mo.dao.MonitorDao;
import com.oitsm.mo.dao.NodeDao;
import com.oitsm.mo.entity.Node;

/**
 * Managed Object Service Implement - 被管理对象的业务实现类
 * @author Arab Runner
 * Jun 25, 2011 12:06:29 PM
 */
@Service
@Transactional
public class MOServiceImpl implements MOService {
	@SuppressWarnings("unused")
	@Autowired
	private MonitorDao monitorDao;
	@Autowired
	private NodeDao nodeDao;
	
	public void setMonitorDao(MonitorDao monitorDao) {
		this.monitorDao = monitorDao;
	}
	public void setNodeDao(NodeDao nodeDao) {
		this.nodeDao = nodeDao;
	}
	
	/**
	 * 添加节点
	 * @param n
	 * @return
	 */
	public Node addNode(Node n){
		nodeDao.addNode(n);
		NodeCache.addNodeToCache(n);
		return n;
	}
	
	/**
	 * 删除节点
	 * @param ids
	 */
	public void deleteNodes(List<Long> ids){
		nodeDao.removeNode(ids);
		NodeCache.removeNodesFormCache(ids);
	}
	
	/**
	 * 修改节点
	 * @param n
	 */
	public void updateNode(Node n){
		nodeDao.updateNode(n);
		NodeCache.mergeNodeToCache(n);
	}
	
	
}
